<%@ include file="/taglibs.jsp" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<head>
	<title>北京邮电大学学生党员在线学习中心</title>
	<link href="${ctx}/css/pagination.css" rel="stylesheet" type="text/css" />
	
	
	<script type="text/javascript">
        
	   var xmlHttp;
	  
		 function changeSecond(value) {
	       if(value != -1) {
               var uri = "AdminAction_getChildrenPaByParentId?parentId=" + escape(value);
               if(window.XMLHttpRequest) {
                   xmlHttp = new XMLHttpRequest();
               } else {
                   try {
                       xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
                   } catch(e) {
                       try {
                           xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
                       } catch(e) {
                           alert("不能创建XMLHttpRequest对象!!!");
                           return;
                   }
               }
           }
                xmlHttp.open("post", uri, true);
                xmlHttp.onreadystatechange = handleResponse;
                xmlHttp.send(null);
       } else {
    	    clearElement1("secondPa");
       }
     }
		 
		  function handleResponse() {
           if(xmlHttp.readyState == 4) {
               if(xmlHttp.status == 200) {
                   updateSelect("secondPa");
                   var idList = xmlHttp.responseXML.getElementsByTagName("id"); 
                   if(idList.length < 1) {
                	   clearElement1("secondPa");
                   } else {
                	   ;
                   }
               }
           }
       }
		  
		  
	  //根据返回的结果更新党支部信息
		function  updateSelect(id) {
			var selectList = document.getElementById(id);
			var idList = xmlHttp.responseXML.getElementsByTagName("id");
			var nameList = xmlHttp.responseXML.getElementsByTagName("branchName");
			if(idList.length > 0) {
				document.getElementById(id).style.display="inline";
				clearElement(id);
				selectList.options.add(new Option('请选择党支部', '-1'));
				for(var i = 0; i<idList.length; i++) {
					selectList.options.add(new Option(nameList[i].firstChild.nodeValue, idList[i].firstChild.nodeValue));
				}
			}
			else{
				document.getElementById(id).style.display="none";
			}
			
		}
		
		 //清除元素
		function clearElement(id) {
			document.getElementById(id).length = 0;
		}
		 
		//当只有一级或者两级党组织时，需要清理遗留的其他党组织信息
		function clearElement1(id) {
		   var selectList = document.getElementById(id);
    	   clearElement(id);
    	   selectList.options.add(new Option('请选择党支部', '-1'));
    	   document.getElementById(id).style.display="none";
		 }
	
	</script> 
	
	
	<script type="text/javascript">
	function exportExcel(currentYear) {
		
		window.location.href = "${ctx}/AdminAction_exportBranchStudyStatistics?currentYear="+currentYear; 
	}
	</script>

</head>
<div id="nav_bar">
    <img id="nav_bar_left" src="../../../styles/nav_bar_left.png" alt=""/>
    <div id="welcome_label">欢迎您，&nbsp;<s:property value="#session.session_user.adminName" />!</div>
    <img id="nav_bar_seperator" src="../../../styles/nav_bar_seperator.png" alt=""/>
    <div id="nav_location">
        <img id="nav_bar_point" src="../../../styles/nav_bar_point.png" alt="" />
        <div id="nav_cur_location">当前位置：&nbsp;<a href="${ctx}/AdminAction_adminPersonCenter">个人中心</a>&nbsp;&nbsp;>&nbsp;&nbsp;<span style="color:black;">党支部学习情况统计</span></div>
    </div>
    <img style="float:right; width:5px;" src="../../../styles/nav_bar_right.png" alt=""/>
    <a id="nav_logout" href="${ctx}/logoutAction_adminLogout">[安全退出]</a>
</div>
<div style="clear:both; height:5px;">&nbsp;</div>

<div style="min-height:450px;">
	<div id="side_menu" style="min-height:740px;">
	    <div id="side_menu_title">
	        <img src="../../../styles/side_menu_title_img.png" alt="" />
	        <span>个人中心</span>
	    </div>
	    <div id="side_menu_title_bottom">&nbsp;</div>
	    <div class="side_sub_menu">
	        <div class="side_menu_point">&nbsp;</div>
	        <a href="${ctx}/AdminAction_adminInfo">查改个人信息</a>
	    </div>
	    <div class="side_menu_seperator">&nbsp;</div>
	    <div class="side_sub_menu">
	        <div class="side_menu_point">&nbsp;</div>
	        <a href="${ctx}/AdminAction_modifyAdminPassword">修改个人密码</a>
	    </div>
	    <div class="side_menu_seperator">&nbsp;</div>
	    <div class="side_sub_menu">
	        <div class="side_menu_point">&nbsp;</div>
	        <a href="${ctx}/AdminAction_personStudyStatistics">个人学习情况统计</a>
	    </div>
	    <div class="side_menu_seperator">&nbsp;</div>
	    <s:if test="#session.level == 2 || #session.level == 3">
	    <div class="side_sub_menu_focus">
	        <div class="side_menu_point">&nbsp;</div>
	        <a href="${ctx}/AdminAction_branchStudyStatistics">党支部学习情况统计</a>
	    </div>
	    </s:if>
	    <s:if test="#session.level == 3">
	    <div class="side_menu_seperator">&nbsp;</div>
	    <div class="side_sub_menu">
	        <div class="side_menu_point">&nbsp;</div>
	        <a href="${ctx}/AdminAction_partyStudyStatistics">分党委学习情况统计</a>
	    </div>
	    </s:if>
	</div>
	
	<div id="main_content">
	    <div id="main_content_title">
	        <img src="../../../styles/content_title_img.png" alt="" />
	        <span>党支部学习情况统计</span>
	    </div>
	    <div class="main_content_title_bottom">&nbsp;</div>
	    
			<s:form action="AdminAction_branchStudyStatistics" name="form1" id="form1" method="post" theme="simple">
					
					<p align="center"><!-- 年份 -->
						 <select id="currentYear" name="currentYear">
						<s:iterator value="year.collection">
						   <s:if test="id == #request.currentYear">
						   <option value="<s:property value='id' />" selected="selected"><s:property value='name' /></option>
						   </s:if>
							<s:else>
							  <option value="<s:property value='id' />" ><s:property value='name'/></option>
							</s:else>
						</s:iterator>
						</select>
					<b><span style="font-size: 20px;">年度在线学习党支部学时统计</span></b>
					
					
					<div style="clear:both; height:20px;"></div>
					
					<%-- <div align="center">
						<input type="submit" name="button" id="button" value="查询" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						<input type="button" name="export" value="导出查询结果" onClick="javascript:exportExcel('<s:property value="currentYear"/>');"/>
						
					</div> --%>
					
					<div align="center">
						<input type="submit" name="button" id="button" value="查询" class="input-button"  style="height:25px; width:40px;"/>
					</div>
					<div align="right">
						<input type="button" name="export" value="导出查询结果" class="input-button" onClick="javascript:exportExcel('<s:property value="currentYear"/>');"/>
						&nbsp;&nbsp;&nbsp;&nbsp;
					</div>
				
			<div style="clear:both; height:10px;"></div>
			
			<table id="theListTable" class="list-table" cellspacing="0" cellpadding="0" >
					<!-- 表头-->
					
						<TR >
							<TH style="width:360px;">
								党支部名称
							</TH>
							<TH >
								党员总数
							</TH>
							<TH >
								完成学时总数
							</TH>
							<TH >
								人均完成学时数
							</TH>
							<TH >
								参与率
							</TH>
						</TR>
					
			
					<!--显示数据列表-->
					<s:iterator value="branchStudyRecordList" status="record" id="record">
						<TR >
							<TD style="width:360px;">
								<s:property value="name"/>
							</TD>
							<TD>
								<s:property value="studentCount"/>
							</TD>
							<TD>
								<s:property value="stutyTimeSum"/>
							</TD>
							<TD>
								<s:property value="averageTime"/>
							</TD>
							<TD>
								<s:property value="branchIdToRateMap.get(id)"/>%
							</TD>
						</TR>
					</s:iterator>
					</table>
			</s:form>
			<div style="clear:both; height:10px;"></div>
			
			<div style="margin-left:0; text-align: center;">
					<s:property value="paginationCode" escape="false"/>
			</div>
	</div>
	<div style="clear:both">&nbsp;</div>
</div>
